﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Usercontrol_ControlThongTinChung : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    string str = webapp4U.Configuration.CurrentConnectionString;
    string error = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["sender"] != null)
            {
                getInfoNPP(Request.QueryString["sender"].ToString());
                GetStoryFirst(Request.QueryString["sender"].ToString());
                Session["sender"] = Request.QueryString["sender"].ToString();
            }
            else
            {
                getInfoNPP(Session["UserName"].ToString());
                GetStoryFirst(Session["UserName"].ToString());
                if (Session["sender"] != null)
                {
                    Session["sender"] = null;
                }
            }
        }
    }
    void GetStoryFirst(string salesp_key)
    {
        dt = new ClassExecute.ClassExecute();
        DataTable db = dt.Get_Data_DataTable(str, ref error, "k_getFirstStory", CommandType.StoredProcedure,
            new SqlParameter("@salesp_key", salesp_key));
        DataStory.DataSource = db;
        DataStory.DataBind();
    }
    void getInfoNPP(string salesp_key)
    {
        dt = new ClassExecute.ClassExecute();
        DataTable db = dt.Get_Data_DataTable(str, ref error, "k_getInfoNPP", CommandType.StoredProcedure,
            new SqlParameter("@salesp_key", salesp_key));
        if (db.Rows.Count > 0)
        {
            DetailsView1.DataSource = db;
            DetailsView1.DataBind();
        }
    }

}